<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Beta Distribution</title>
<link rel="stylesheet" href="../../../math.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../../index.html" title="Math Toolkit 4.2.0">
<link rel="up" href="../dists.html" title="Distributions">
<link rel="prev" href="bernoulli_dist.html" title="Bernoulli Distribution">
<link rel="next" href="binomial_dist.html" title="Binomial Distribution">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="bernoulli_dist.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../dists.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="binomial_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="math_toolkit.dist_ref.dists.beta_dist"></a><a class="link" href="beta_dist.html" title="Beta Distribution">Beta Distribution</a>
</h4></div></div></div>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">distributions</span><span class="special">/</span><span class="identifier">beta</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></pre>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span>

 <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">RealType</span> <span class="special">=</span> <span class="keyword">double</span><span class="special">,</span>
           <span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 22. Policies: Controlling Precision, Error Handling etc">Policy</a>   <span class="special">=</span> <a class="link" href="../../pol_ref/pol_ref_ref.html" title="Policy Class Reference">policies::policy&lt;&gt;</a> <span class="special">&gt;</span>
<span class="keyword">class</span> <span class="identifier">beta_distribution</span><span class="special">;</span>

<span class="comment">// typedef beta_distribution&lt;double&gt; beta;</span>
<span class="comment">// Note that this is deliberately NOT provided,</span>
<span class="comment">// to avoid a clash with the function name beta.</span>

<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">RealType</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../../../policy.html" title="Chapter 22. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
<span class="keyword">class</span> <span class="identifier">beta_distribution</span>
<span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
   <span class="keyword">typedef</span> <span class="identifier">RealType</span>  <span class="identifier">value_type</span><span class="special">;</span>
   <span class="keyword">typedef</span> <span class="identifier">Policy</span>    <span class="identifier">policy_type</span><span class="special">;</span>
   <span class="comment">// Constructor from two shape parameters, alpha &amp; beta:</span>
   <span class="identifier">beta_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">b</span><span class="special">);</span>

   <span class="comment">// Parameter accessors:</span>
   <span class="identifier">RealType</span> <span class="identifier">alpha</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
   <span class="identifier">RealType</span> <span class="identifier">beta</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>

   <span class="comment">// Parameter estimators of alpha or beta from mean and variance.</span>
   <span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_alpha</span><span class="special">(</span>
     <span class="identifier">RealType</span> <span class="identifier">mean</span><span class="special">,</span> <span class="comment">// Expected value of mean.</span>
     <span class="identifier">RealType</span> <span class="identifier">variance</span><span class="special">);</span> <span class="comment">// Expected value of variance.</span>

   <span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_beta</span><span class="special">(</span>
     <span class="identifier">RealType</span> <span class="identifier">mean</span><span class="special">,</span> <span class="comment">// Expected value of mean.</span>
     <span class="identifier">RealType</span> <span class="identifier">variance</span><span class="special">);</span> <span class="comment">// Expected value of variance.</span>

   <span class="comment">// Parameter estimators from</span>
   <span class="comment">// either alpha or beta, and x and probability.</span>

   <span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_alpha</span><span class="special">(</span>
     <span class="identifier">RealType</span> <span class="identifier">beta</span><span class="special">,</span> <span class="comment">// from beta.</span>
     <span class="identifier">RealType</span> <span class="identifier">x</span><span class="special">,</span> <span class="comment">//  x.</span>
     <span class="identifier">RealType</span> <span class="identifier">probability</span><span class="special">);</span> <span class="comment">// cdf</span>

   <span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_beta</span><span class="special">(</span>
     <span class="identifier">RealType</span> <span class="identifier">alpha</span><span class="special">,</span> <span class="comment">// alpha.</span>
     <span class="identifier">RealType</span> <span class="identifier">x</span><span class="special">,</span> <span class="comment">// probability x.</span>
     <span class="identifier">RealType</span> <span class="identifier">probability</span><span class="special">);</span> <span class="comment">// probability cdf.</span>
<span class="special">};</span>

<span class="special">}}</span> <span class="comment">// namespaces</span>
</pre>
<p>
          The class type <code class="computeroutput"><span class="identifier">beta_distribution</span></code>
          represents a <a href="http://en.wikipedia.org/wiki/Beta_distribution" target="_top">beta
          </a> <a href="http://en.wikipedia.org/wiki/Probability_distribution" target="_top">probability
          distribution function</a>.
        </p>
<p>
          The <a href="http://mathworld.wolfram.com/BetaDistribution.htm" target="_top">beta
          distribution </a> is used as a <a href="http://en.wikipedia.org/wiki/Prior_distribution" target="_top">prior
          distribution</a> for binomial proportions in <a href="http://mathworld.wolfram.com/BayesianAnalysis.html" target="_top">Bayesian
          analysis</a>.
        </p>
<p>
          See also: <a href="http://documents.wolfram.com/calculationcenter/v2/Functions/ListsMatrices/Statistics/BetaDistribution.html" target="_top">beta
          distribution</a> and <a href="http://en.wikipedia.org/wiki/Bayesian_statistics" target="_top">Bayesian
          statistics</a>.
        </p>
<p>
          How the beta distribution is used for <a href="http://home.uchicago.edu/~grynav/bayes/ABSLec5.ppt" target="_top">Bayesian
          analysis of one parameter models</a> is discussed by Jeff Grynaviski.
        </p>
<p>
          The <a href="http://en.wikipedia.org/wiki/Probability_density_function" target="_top">probability
          density function PDF</a> for the <a href="http://en.wikipedia.org/wiki/Beta_distribution" target="_top">beta
          distribution</a> defined on the interval [0,1] is given by:
        </p>
<div class="blockquote"><blockquote class="blockquote"><p>
            <span class="serif_italic">f(x;α,β) = x<sup>α - 1</sup> (1 - x)<sup>β -1</sup> / B(α, β)</span>
          </p></blockquote></div>
<p>
          where <span class="serif_italic">B(α, β)</span> is the <a href="http://en.wikipedia.org/wiki/Beta_function" target="_top">beta
          function</a>, implemented in this library as <a class="link" href="../../sf_beta/beta_function.html" title="Beta">beta</a>.
          Division by the beta function ensures that the pdf is normalized to the
          range zero to unity.
        </p>
<p>
          The following graph illustrates examples of the pdf for various values
          of the shape parameters. Note the <span class="emphasis"><em>α = β = 2</em></span> (blue line)
          is dome-shaped, and might be approximated by a symmetrical triangular distribution.
        </p>
<div class="blockquote"><blockquote class="blockquote"><p>
            <span class="inlinemediaobject"><img src="../../../../graphs/beta_pdf.svg" align="middle"></span>

          </p></blockquote></div>
<p>
          If α = β = 1, then it is a  
<a href="http://en.wikipedia.org/wiki/Uniform_distribution_%28continuous%29" target="_top">uniform
          distribution</a>, equal to unity in the entire interval x = 0 to 1.
          If α and β are &lt; 1, then the pdf is U-shaped. If α != β, then the shape is
          asymmetric and could be approximated by a triangle whose apex is away from
          the centre (where x = half).
        </p>
<h5>
<a name="math_toolkit.dist_ref.dists.beta_dist.h0"></a>
          <span class="phrase"><a name="math_toolkit.dist_ref.dists.beta_dist.member_functions"></a></span><a class="link" href="beta_dist.html#math_toolkit.dist_ref.dists.beta_dist.member_functions">Member
          Functions</a>
        </h5>
<h6>
<a name="math_toolkit.dist_ref.dists.beta_dist.h1"></a>
          <span class="phrase"><a name="math_toolkit.dist_ref.dists.beta_dist.constructor"></a></span><a class="link" href="beta_dist.html#math_toolkit.dist_ref.dists.beta_dist.constructor">Constructor</a>
        </h6>
<pre class="programlisting"><span class="identifier">beta_distribution</span><span class="special">(</span><span class="identifier">RealType</span> <span class="identifier">alpha</span><span class="special">,</span> <span class="identifier">RealType</span> <span class="identifier">beta</span><span class="special">);</span>
</pre>
<p>
          Constructs a beta distribution with shape parameters <span class="emphasis"><em>alpha</em></span>
          and <span class="emphasis"><em>beta</em></span>.
        </p>
<p>
          Requires alpha,beta &gt; 0,otherwise <a class="link" href="../../error_handling.html#math_toolkit.error_handling.domain_error">domain_error</a>
          is called. Note that technically the beta distribution is defined for alpha,beta
          &gt;= 0, but it's not clear whether any program can actually make use of
          that latitude or how many of the non-member functions can be usefully defined
          in that case. Therefore for now, we regard it as an error if alpha or beta
          is zero.
        </p>
<p>
          For example:
        </p>
<pre class="programlisting"><span class="identifier">beta_distribution</span><span class="special">&lt;&gt;</span> <span class="identifier">mybeta</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="number">5</span><span class="special">);</span>
</pre>
<p>
          Constructs a the beta distribution with alpha=2 and beta=5 (shown in yellow
          in the graph above).
        </p>
<h6>
<a name="math_toolkit.dist_ref.dists.beta_dist.h2"></a>
          <span class="phrase"><a name="math_toolkit.dist_ref.dists.beta_dist.parameter_accessors"></a></span><a class="link" href="beta_dist.html#math_toolkit.dist_ref.dists.beta_dist.parameter_accessors">Parameter
          Accessors</a>
        </h6>
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">alpha</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
</pre>
<p>
          Returns the parameter <span class="emphasis"><em>alpha</em></span> from which this distribution
          was constructed.
        </p>
<pre class="programlisting"><span class="identifier">RealType</span> <span class="identifier">beta</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span>
</pre>
<p>
          Returns the parameter <span class="emphasis"><em>beta</em></span> from which this distribution
          was constructed.
        </p>
<p>
          So for example:
        </p>
<pre class="programlisting"><span class="identifier">beta_distribution</span><span class="special">&lt;&gt;</span> <span class="identifier">mybeta</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="number">5</span><span class="special">);</span>
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">mybeta</span><span class="special">.</span><span class="identifier">alpha</span><span class="special">()</span> <span class="special">==</span> <span class="number">2.</span><span class="special">);</span>  <span class="comment">// mybeta.alpha() returns 2</span>
<span class="identifier">assert</span><span class="special">(</span><span class="identifier">mybeta</span><span class="special">.</span><span class="identifier">beta</span><span class="special">()</span> <span class="special">==</span> <span class="number">5.</span><span class="special">);</span>   <span class="comment">// mybeta.beta()  returns 5</span>
</pre>
<h5>
<a name="math_toolkit.dist_ref.dists.beta_dist.h3"></a>
          <span class="phrase"><a name="math_toolkit.dist_ref.dists.beta_dist.parameter_estimators"></a></span><a class="link" href="beta_dist.html#math_toolkit.dist_ref.dists.beta_dist.parameter_estimators">Parameter
          Estimators</a>
        </h5>
<p>
          Two pairs of parameter estimators are provided.
        </p>
<p>
          One estimates either α  or β 
from presumed-known mean and variance.
        </p>
<p>
          The other pair estimates either α or β from the cdf and x.
        </p>
<p>
          It is also possible to estimate α and β  from 'known' mode &amp; quantile. For
          example, calculators are provided by the <a href="http://www.ausvet.com.au/pprev/content.php?page=PPscript" target="_top">Pooled
          Prevalence Calculator</a> and <a href="http://www.epi.ucdavis.edu/diagnostictests/betabuster.html" target="_top">Beta
          Buster</a> but this is not yet implemented here.
        </p>
<pre class="programlisting"><span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_alpha</span><span class="special">(</span>
  <span class="identifier">RealType</span> <span class="identifier">mean</span><span class="special">,</span> <span class="comment">// Expected value of mean.</span>
  <span class="identifier">RealType</span> <span class="identifier">variance</span><span class="special">);</span> <span class="comment">// Expected value of variance.</span>
</pre>
<p>
          Returns the unique value of α that corresponds to a beta distribution with
          mean <span class="emphasis"><em>mean</em></span> and variance <span class="emphasis"><em>variance</em></span>.
        </p>
<pre class="programlisting"><span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_beta</span><span class="special">(</span>
  <span class="identifier">RealType</span> <span class="identifier">mean</span><span class="special">,</span> <span class="comment">// Expected value of mean.</span>
  <span class="identifier">RealType</span> <span class="identifier">variance</span><span class="special">);</span> <span class="comment">// Expected value of variance.</span>
</pre>
<p>
          Returns the unique value of β that corresponds to a beta distribution with
          mean <span class="emphasis"><em>mean</em></span> and variance <span class="emphasis"><em>variance</em></span>.
        </p>
<pre class="programlisting"><span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_alpha</span><span class="special">(</span>
  <span class="identifier">RealType</span> <span class="identifier">beta</span><span class="special">,</span> <span class="comment">// from beta.</span>
  <span class="identifier">RealType</span> <span class="identifier">x</span><span class="special">,</span> <span class="comment">//  x.</span>
  <span class="identifier">RealType</span> <span class="identifier">probability</span><span class="special">);</span> <span class="comment">// probability cdf</span>
</pre>
<p>
          Returns the value of α that gives: <code class="computeroutput"><span class="identifier">cdf</span><span class="special">(</span><span class="identifier">beta_distribution</span><span class="special">&lt;</span><span class="identifier">RealType</span><span class="special">&gt;(</span><span class="identifier">alpha</span><span class="special">,</span> <span class="identifier">beta</span><span class="special">),</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">==</span> <span class="identifier">probability</span></code>.
        </p>
<pre class="programlisting"><span class="keyword">static</span> <span class="identifier">RealType</span> <span class="identifier">find_beta</span><span class="special">(</span>
  <span class="identifier">RealType</span> <span class="identifier">alpha</span><span class="special">,</span> <span class="comment">// alpha.</span>
  <span class="identifier">RealType</span> <span class="identifier">x</span><span class="special">,</span> <span class="comment">// probability x.</span>
  <span class="identifier">RealType</span> <span class="identifier">probability</span><span class="special">);</span> <span class="comment">// probability cdf.</span>
</pre>
<p>
          Returns the value of β that gives: <code class="computeroutput"><span class="identifier">cdf</span><span class="special">(</span><span class="identifier">beta_distribution</span><span class="special">&lt;</span><span class="identifier">RealType</span><span class="special">&gt;(</span><span class="identifier">alpha</span><span class="special">,</span> <span class="identifier">beta</span><span class="special">),</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">==</span> <span class="identifier">probability</span></code>.
        </p>
<h5>
<a name="math_toolkit.dist_ref.dists.beta_dist.h4"></a>
          <span class="phrase"><a name="math_toolkit.dist_ref.dists.beta_dist.non_member_accessor_functions"></a></span><a class="link" href="beta_dist.html#math_toolkit.dist_ref.dists.beta_dist.non_member_accessor_functions">Non-member
          Accessor Functions</a>
        </h5>
<p>
          All the <a class="link" href="../nmp.html" title="Non-Member Properties">usual non-member accessor
          functions</a> that are generic to all distributions are supported:
          <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.cdf">Cumulative Distribution Function</a>,
          <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.pdf">Probability Density Function</a>,
          <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.quantile">Quantile</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.hazard">Hazard Function</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.chf">Cumulative Hazard Function</a>,
          <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.mean">mean</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.median">median</a>,
          <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.mode">mode</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.variance">variance</a>,
          <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.sd">standard deviation</a>,
          <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.skewness">skewness</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.kurtosis">kurtosis</a>, <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.kurtosis_excess">kurtosis_excess</a>,
          <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.range">range</a> and <a class="link" href="../nmp.html#math_toolkit.dist_ref.nmp.support">support</a>.
        </p>
<p>
          The formulae for calculating these are shown in the table below, and at
          <a href="http://mathworld.wolfram.com/BetaDistribution.html" target="_top">Wolfram
          Mathworld</a>.
        </p>
<h5>
<a name="math_toolkit.dist_ref.dists.beta_dist.h5"></a>
          <span class="phrase"><a name="math_toolkit.dist_ref.dists.beta_dist.applications"></a></span><a class="link" href="beta_dist.html#math_toolkit.dist_ref.dists.beta_dist.applications">Applications</a>
        </h5>
<p>
          The beta distribution can be used to model events constrained to take place
          within an interval defined by a minimum and maximum value: so it is used
          in project management systems.
        </p>
<p>
          It is also widely used in <a href="http://en.wikipedia.org/wiki/Bayesian_inference" target="_top">Bayesian
          statistical inference</a>.
        </p>
<h5>
<a name="math_toolkit.dist_ref.dists.beta_dist.h6"></a>
          <span class="phrase"><a name="math_toolkit.dist_ref.dists.beta_dist.related_distributions"></a></span><a class="link" href="beta_dist.html#math_toolkit.dist_ref.dists.beta_dist.related_distributions">Related
          distributions</a>
        </h5>
<p>
          The beta distribution with both α and β = 1 follows a <a href="http://en.wikipedia.org/wiki/Uniform_distribution_%28continuous%29" target="_top">uniform
          distribution</a>.
        </p>
<p>
          The <a href="http://en.wikipedia.org/wiki/Triangular_distribution" target="_top">triangular</a>
          is used when less precise information is available.
        </p>
<p>
          The <a href="http://en.wikipedia.org/wiki/Binomial_distribution" target="_top">binomial
          distribution</a> is closely related when α and β  are integers.
        </p>
<p>
          With integer values of α  and β the distribution B(i, j) is that of the j-th
          highest of a sample of i + j + 1 independent random variables uniformly
          distributed between 0 and 1. The cumulative probability from 0 to x is
          thus the probability that the j-th highest value is less than x. Or it
          is the probability that at least i of the random variables are less than
          x, a probability given by summing over the <a class="link" href="binomial_dist.html" title="Binomial Distribution">Binomial
          Distribution</a> with its p parameter set to x.
        </p>
<h5>
<a name="math_toolkit.dist_ref.dists.beta_dist.h7"></a>
          <span class="phrase"><a name="math_toolkit.dist_ref.dists.beta_dist.accuracy"></a></span><a class="link" href="beta_dist.html#math_toolkit.dist_ref.dists.beta_dist.accuracy">Accuracy</a>
        </h5>
<p>
          This distribution is implemented using the <a class="link" href="../../sf_beta/beta_function.html" title="Beta">beta
          functions</a> <a class="link" href="../../sf_beta/beta_function.html" title="Beta">beta</a>
          and <a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">incomplete beta
          functions</a> <a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">ibeta</a>
          and <a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">ibetac</a>;
          please refer to these functions for information on accuracy.
        </p>
<h5>
<a name="math_toolkit.dist_ref.dists.beta_dist.h8"></a>
          <span class="phrase"><a name="math_toolkit.dist_ref.dists.beta_dist.implementation"></a></span><a class="link" href="beta_dist.html#math_toolkit.dist_ref.dists.beta_dist.implementation">Implementation</a>
        </h5>
<p>
          In the following table <span class="emphasis"><em>a</em></span> and <span class="emphasis"><em>b</em></span>
          are the parameters α and β, <span class="emphasis"><em>x</em></span> is the random variable,
          <span class="emphasis"><em>p</em></span> is the probability and <span class="emphasis"><em>q = 1-p</em></span>.
        </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                  <p>
                    Function
                  </p>
                </th>
<th>
                  <p>
                    Implementation Notes
                  </p>
                </th>
</tr></thead>
<tbody>
<tr>
<td>
                  <p>
                    pdf
                  </p>
                </td>
<td>
                  <p>
                    <span class="serif_italic">f(x;α,β) = x<sup>α - 1</sup> (1 - x)<sup>β -1</sup> / B(α, β)</span>
                  </p>
                  <p>
                    Implemented using <a class="link" href="../../sf_beta/beta_derivative.html" title="Derivative of the Incomplete Beta Function">ibeta_derivative</a>(a,
                    b, x).
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    cdf
                  </p>
                </td>
<td>
                  <p>
                    Using the incomplete beta function <a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">ibeta</a>(a,
                    b, x)
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    cdf complement
                  </p>
                </td>
<td>
                  <p>
                    <a class="link" href="../../sf_beta/ibeta_function.html" title="Incomplete Beta Functions">ibetac</a>(a,
                    b, x)
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    quantile
                  </p>
                </td>
<td>
                  <p>
                    Using the inverse incomplete beta function <a class="link" href="../../sf_beta/ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">ibeta_inv</a>(a,
                    b, p)
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    quantile from the complement
                  </p>
                </td>
<td>
                  <p>
                    <a class="link" href="../../sf_beta/ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">ibetac_inv</a>(a,
                    b, q)
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    mean
                  </p>
                </td>
<td>
                  <p>
                    <code class="computeroutput"><span class="identifier">a</span><span class="special">/(</span><span class="identifier">a</span><span class="special">+</span><span class="identifier">b</span><span class="special">)</span></code>
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    variance
                  </p>
                </td>
<td>
                  <p>
                    <code class="computeroutput"><span class="identifier">a</span> <span class="special">*</span>
                    <span class="identifier">b</span> <span class="special">/</span>
                    <span class="special">(</span><span class="identifier">a</span><span class="special">+</span><span class="identifier">b</span><span class="special">)^</span><span class="number">2</span> <span class="special">*</span> <span class="special">(</span><span class="identifier">a</span> <span class="special">+</span>
                    <span class="identifier">b</span> <span class="special">+</span>
                    <span class="number">1</span><span class="special">)</span></code>
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    mode
                  </p>
                </td>
<td>
                  <p>
                    <code class="computeroutput"><span class="special">(</span><span class="identifier">a</span><span class="special">-</span><span class="number">1</span><span class="special">)</span> <span class="special">/</span>
                    <span class="special">(</span><span class="identifier">a</span>
                    <span class="special">+</span> <span class="identifier">b</span>
                    <span class="special">-</span> <span class="number">2</span><span class="special">)</span></code>
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    skewness
                  </p>
                </td>
<td>
                  <p>
                    <code class="computeroutput"><span class="number">2</span> <span class="special">(</span><span class="identifier">b</span><span class="special">-</span><span class="identifier">a</span><span class="special">)</span>
                    <span class="identifier">sqrt</span><span class="special">(</span><span class="identifier">a</span><span class="special">+</span><span class="identifier">b</span><span class="special">+</span><span class="number">1</span><span class="special">)/(</span><span class="identifier">a</span><span class="special">+</span><span class="identifier">b</span><span class="special">+</span><span class="number">2</span><span class="special">)</span> <span class="special">*</span> <span class="identifier">sqrt</span><span class="special">(</span><span class="identifier">a</span>
                    <span class="special">*</span> <span class="identifier">b</span><span class="special">)</span></code>
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    kurtosis excess
                  </p>
                </td>
<td>
                  <div class="blockquote"><blockquote class="blockquote"><p>
                      <span class="inlinemediaobject"><img src="../../../../equations/beta_dist_kurtosis.svg"></span>

                    </p></blockquote></div>
                </td>
</tr>
<tr>
<td>
                  <p>
                    kurtosis
                  </p>
                </td>
<td>
                  <p>
                    <code class="computeroutput"><span class="identifier">kurtosis</span> <span class="special">+</span>
                    <span class="number">3</span></code>
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    parameter estimation
                  </p>
                </td>
<td>
                </td>
</tr>
<tr>
<td>
                  <p>
                    alpha (from mean and variance)
                  </p>
                </td>
<td>
                  <p>
                    <code class="computeroutput"><span class="identifier">mean</span> <span class="special">*</span>
                    <span class="special">((</span> <span class="special">(</span><span class="identifier">mean</span> <span class="special">*</span>
                    <span class="special">(</span><span class="number">1</span>
                    <span class="special">-</span> <span class="identifier">mean</span><span class="special">))</span> <span class="special">/</span>
                    <span class="identifier">variance</span><span class="special">)-</span>
                    <span class="number">1</span><span class="special">)</span></code>
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    beta (from mean and variance)
                  </p>
                </td>
<td>
                  <p>
                    <code class="computeroutput"><span class="special">(</span><span class="number">1</span>
                    <span class="special">-</span> <span class="identifier">mean</span><span class="special">)</span> <span class="special">*</span>
                    <span class="special">(((</span><span class="identifier">mean</span>
                    <span class="special">*</span> <span class="special">(</span><span class="number">1</span> <span class="special">-</span> <span class="identifier">mean</span><span class="special">))</span>
                    <span class="special">/</span><span class="identifier">variance</span><span class="special">)-</span><span class="number">1</span><span class="special">)</span></code>
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    The member functions <code class="computeroutput"><span class="identifier">find_alpha</span></code>
                    and <code class="computeroutput"><span class="identifier">find_beta</span></code>
                  </p>
                  <p>
                    from cdf and probability x
                  </p>
                  <p>
                    and <span class="bold"><strong>either</strong></span> <code class="computeroutput"><span class="identifier">alpha</span></code>
                    or <code class="computeroutput"><span class="identifier">beta</span></code>
                  </p>
                </td>
<td>
                  <p>
                    Implemented in terms of the inverse incomplete beta functions
                  </p>
                  <p>
                    <a class="link" href="../../sf_beta/ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">ibeta_inva</a>,
                    and <a class="link" href="../../sf_beta/ibeta_inv_function.html" title="The Incomplete Beta Function Inverses">ibeta_invb</a>
                    respectively.
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    <code class="computeroutput"><span class="identifier">find_alpha</span></code>
                  </p>
                </td>
<td>
                  <p>
                    <code class="computeroutput"><span class="identifier">ibeta_inva</span><span class="special">(</span><span class="identifier">beta</span><span class="special">,</span>
                    <span class="identifier">x</span><span class="special">,</span>
                    <span class="identifier">probability</span><span class="special">)</span></code>
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    <code class="computeroutput"><span class="identifier">find_beta</span></code>
                  </p>
                </td>
<td>
                  <p>
                    <code class="computeroutput"><span class="identifier">ibeta_invb</span><span class="special">(</span><span class="identifier">alpha</span><span class="special">,</span>
                    <span class="identifier">x</span><span class="special">,</span>
                    <span class="identifier">probability</span><span class="special">)</span></code>
                  </p>
                </td>
</tr>
</tbody>
</table></div>
<h5>
<a name="math_toolkit.dist_ref.dists.beta_dist.h9"></a>
          <span class="phrase"><a name="math_toolkit.dist_ref.dists.beta_dist.references"></a></span><a class="link" href="beta_dist.html#math_toolkit.dist_ref.dists.beta_dist.references">References</a>
        </h5>
<p>
          <a href="http://en.wikipedia.org/wiki/Beta_distribution" target="_top">Wikipedia Beta
          distribution</a>
        </p>
<p>
          <a href="http://www.itl.nist.gov/div898/handbook/eda/section3/eda366h.htm" target="_top">NIST
          Exploratory Data Analysis</a>
        </p>
<p>
          <a href="http://mathworld.wolfram.com/BetaDistribution.html" target="_top">Wolfram
          MathWorld</a>
        </p>
</div>
<div class="copyright-footer">Copyright © 2006-2021 Nikhar Agrawal, Anton Bikineev, Matthew Borland,
      Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert Holin, Bruno
      Lalande, John Maddock, Evan Miller, Jeremy Murphy, Matthew Pulver, Johan Råde,
      Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg, Daryle
      Walker and Xiaogang Zhang<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="bernoulli_dist.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../dists.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="binomial_dist.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
